package com.migu.spms.webapi;

import javax.annotation.Resource;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import com.migu.spms.service.data.User;
import com.migu.spms.service.inf.ICreateBaselineService;
import com.migu.spms.webapi.data.CreateBaselineRequest;

/**
 * 
* 项目名称:  SPMS需求管理
* 包:        com.migu.spms.webapi 
* 类名称:    CreateRequireController.java
* 类描述:    新建基线控制类
* 创建人:    fw  
* 创建时间:  2017年6月13日 下午4:29:02
 */
// @codeCreate.restfulAPICreate.util.annotation.type.Controller(introduction =
// "新建基线")
@RestController
@RequestMapping(value = "/baseline", produces = "application/json;charset=UTF-8")
public class CreateBaselineController extends BaseController {
    @Resource(name = "createBaselineService")
    ICreateBaselineService createBaselineService;
    

    // @Method(introduction = "新建基线", requestType = CreateBaselineRequest.class,
    // responseType = GeneralResponse.class)
    @RequestMapping(value = "/create")
    public String create(HttpServletRequest req, HttpServletResponse resp, String sessionId) throws Exception {
        User user = getUserBySession(req, sessionId);
        if (user == null) {
            return generateResponse(401);
        }
//        User user = new User();
//        user.setUserId(1);
//        user.setUserName("zs");
        CreateBaselineRequest createBaselineRequest = ParseMsg(req, CreateBaselineRequest.class);
        createBaselineService.create(createBaselineRequest, user);
        return generateResponse(200);

    }
}
